package org.example.weather.app;

import org.example.weather.core.WeatherData;
import org.example.weather.core.WeatherService;
import org.example.weather.storage.WeatherServiceImpl;

import java.util.Scanner;
import java.time.LocalDate;

public class Main {
    public static void main(String[] args) {
        WeatherService weatherService = new WeatherServiceImpl();
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("1. Record Weather Data");
            System.out.println("2. Query Weather Data by Location");
            System.out.println("3. Exit");
            System.out.print("Choose an option: ");
            int choice = scanner.nextInt();

            if (choice == 1) {
                System.out.print("Enter location: ");
                String location = scanner.next();
                System.out.print("Enter temperature: ");
                double temperature = scanner.nextDouble();
                System.out.print("Enter humidity: ");
                double humidity = scanner.nextDouble();
                weatherService.recordWeatherData(new WeatherData(location, temperature, humidity, LocalDate.now()));
            } else if (choice == 2) {
                System.out.print("Enter location: ");
                String location = scanner.next();
                weatherService.getWeatherDataByLocation(location).forEach(System.out::println);
            } else if (choice == 3) {
                break;
            }
        }
        scanner.close();
    }
}
